<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>消息管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

    <!--  easyui.css  -->
    <link rel="stylesheet" type="text/css" href="css/easyui/themes/default/easyui.css">
    <!--  icon.css  -->
    <link rel="stylesheet" type="text/css" href="css/easyui/themes/icon.css">
    <!--  color.css  -->
    <link rel="stylesheet" type="text/css" href="css/easyui/themes/color.css">
    <!--  demo.css  -->
    <link rel="stylesheet" type="text/css" href="css/easyui/demo/demo.css">
    <!--  jquery-1.6.min.js -->
    <script type="text/javascript" src="js/jquery/1.6/jquery-1.6.min.js"></script>
    <!--  jquery.easyui.min.js  -->
    <script type="text/javascript" src="js/easyui/1.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/easyui/1.4/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="js/easyui/1.4/common.js"></script>

    <style type="text/css">
        #fm{
            margin:0;
            padding:10px 30px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
        .fitem input{
            width:160px;
        }
    </style>
  </head>
  <body>
  <div id="query_parmas">
  </div>
<table id="dg" title="用户消息管理" class="easyui-datagrid" style="width:700px;height:600px"
            url="admin/getMsgListBy.do"
            toolbar="#toolbar" pagination="true"
            rownumbers="true" fitColumns="true" singleSelect="true"
            >
        <thead>
            <tr>
            	<th field="messageId"  width="50" >消息Id</th>
                <th field="messageMsg" width="60" >消息信息</th>
                <th field="userId" width="60">消息用户Id</th>
                <th field="createDate" formatter="Common.DateFormatter" width="60" >消息创建时间</th>
            </tr>	
        </thead>
    </table>
    <div id="toolbar">
    	<div id="searchtool" style="padding:5px">
        <span>用户Id&nbsp;&nbsp;&nbsp;:</span><input id="userId" type="text" value="" size=10 />
        <span>创建日期:</span><input type="text" id="createDateFrom" size=10 class="easyui-datebox" /><span>-</span><input id="createDateTo"type="text" size=10 class="easyui-datebox" />
        <a href="javascript:void(0)" id="queryButton" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="loadByParams();">查询</a>  
        </div>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteMsg()">删除消息</a>
    </div>

  </body>
  <script type="text/javascript">

        function loadByParams(){

        	 $('#dg').datagrid('load'
        		              ,{userId : $('#userId').val(),
								createDateFrom: $('#createDateFrom').val(),
								createDateTo: $('#createDateTo').val()
				                }
	        );
        }

        function deleteMsg(){
            var row = $('#dg').datagrid('getSelected');
            if (row){
                $.messager.confirm('Confirm','你确定要删除这笔消息吗？',function(r){
                    if (r){
                        $.post('admin/delete_msg.do',{messageId:row.messageId},function(result){
                            if (result.falg){
                                $.messager.alert('成功提示','删除成功！','info');
                                $('#dg').datagrid('reload'); // reload the order data
                            } else {
                                $.messager.show({    // show error message
                                    title: 'Error',
                                    msg: result.errorMsg
                                });
                            }
                        },'json');
                    }
                });
            }
        }
    </script>
</html>
